var utils = require('../../../../utils/util.js')
Page({

  data: {
    userinfo: [],
    sex: 0,
    token: ""
  },
  onLoad: function (options) {
    this.setData({
      userinfo: wx.getStorageSync("userinfo"),
      token: wx.getStorageSync("userinfo").wap_token,
      sex: wx.getStorageSync("userinfo").sex
    })
  },
  onShow: function () {

  },
  editUsersex: function (e) {
    this.setData({
      sex: e.detail.value
    })
  },
  editUser: function () {
    var sex = this.data.sex;
    var token = this.data.token;
    var data = {
      url: "/wsgoods/user/edit",
      token: token,
      ext: "sex",
      value: sex
    };
    utils.request(data).then(function (res) {
      if (res.code == 0) {
        wx.showToast({
          title: "修改成功",
          icon: 'none',
          duration: 1500
        })
        utils.updateUserinfo();
        setTimeout(function () {
          wx.navigateBack({
            delta: 1
          })
        }, 1500);
      } else {
        wx.showToast({
          title: res.msg,
          icon: 'none',
          duration: 1500
        })
      }
    });
  },
})